<%@ page import="java.util.List" %>
<%@ page import="com.gfxy.vo.Notice" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>

<!DOCTYPE html>

<html lang="en" class="material-style layout-fixed">

<head>
    <title>Bhumlu | B4+ admin template by Srthemesvilla</title>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="Bhumlu Bootstrap admin template made using Bootstrap 4, it has tons of ready made feature, UI components, pages which completely fulfills any dashboard needs." />
    <meta name="keywords" content="Bhumlu, bootstrap admin template, bootstrap admin panel, bootstrap 4 admin template, admin template">
    <meta name="author" content="Srthemesvilla" />
    <link rel="icon" type="image/x-icon" href="assets/img/favicon.ico">

    <!-- Google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet">

    <!-- Icon fonts -->
    <link rel="stylesheet" href="assets/fonts/fontawesome.css">
    <link rel="stylesheet" href="assets/fonts/ionicons.css">
    <link rel="stylesheet" href="assets/fonts/linearicons.css">
    <link rel="stylesheet" href="assets/fonts/open-iconic.css">
    <link rel="stylesheet" href="assets/fonts/pe-icon-7-stroke.css">
    <link rel="stylesheet" href="assets/fonts/feather.css">

    <!-- Core stylesheets -->
    <link rel="stylesheet" href="assets/css/bootstrap-material.css">
    <link rel="stylesheet" href="assets/css/shreerang-material.css">
    <link rel="stylesheet" href="assets/css/uikit.css">

    <!-- Libs -->
    <link rel="stylesheet" href="assets/libs/perfect-scrollbar/perfect-scrollbar.css">

</head>

<body>
<!-- [ Preloader ] Start -->
<div class="page-loader">
    <div class="bg-primary"></div>
</div>
<!-- [ Preloader ] Ebd -->

<!-- [ Layout wrapper ] Start -->
<div class="layout-wrapper layout-2">
    <div class="layout-inner">
        <!-- [ Layout sidenav ] Start -->
        <jsp:include page="common/left-menu.jsp"/>
        <!-- [ Layout sidenav ] End -->
        <!-- [ Layout container ] Start -->
        <div class="layout-container">
            <!-- [ Layout navbar ( Header ) ] Start -->
            <jsp:include page="common/header.jsp"/>
            <!-- [ Layout navbar ( Header ) ] End -->

            <!-- [ Layout content ] Start -->
            <div class="layout-content">

                <!-- [ content ] Start -->
                <div class="container-fluid flex-grow-1 container-p-y">

                    <div class="card">
                        <div class="card-header">通知通告</div>
                        <div class="card mb-4">
                            <div class="card-body">
                                <form class="form-inline mb-4">
                                    <div class="form-row">
                                        <div class="input-group mr-sm-2 mb-2 mb-sm-0">
                                            <label class="form-label">标题:</label>
                                            <input type="text" class="form-control" id="t_title" placeholder="请输入标题:">
                                        </div>
                                        <div class="input-group mr-sm-2 mb-2 mb-sm-0">
                                            <label class="form-label">内容:</label>
                                            <input type="text" id="t_content" class="form-control" placeholder="请输入内容:">
                                        </div>
                                        <button type="button" class="btn btn-primary" onclick="selectNotice()">搜索</button>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="demo-inline-spacing mt-3" style="margin-left: 20px">
                            <button type="button" class="btn btn-primary" onclick="toAddNoticePage()">新增通告</button>
                            <button type="button" class="btn btn-secondary">删除</button>
                        </div>

                        <table class="table card-table">
                            <thead class="thead-light">
                            <tr>
                                <th>ID</th>
                                <th>标题</th>
                                <th>内容</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>

                            <%
                                List<Notice> noticeList = (List<Notice>)request.getAttribute("noticeList");
                                for(int i =0; i<noticeList.size(); i++){
                            %>
                                <tr>
                                    <th scope="row"><%=noticeList.get(i).getNoticeId()%></th>
                                    <td><%=noticeList.get(i).getNoticeTitle()%></td>
                                    <td><%=noticeList.get(i).getNoticeContent()%></td>
                                    <td>@mdo</td>
                                    <td><a href="toUpdateNoticePage?noticeId=<%=noticeList.get(i).getNoticeId()%>">修改</a> &nbsp;&nbsp;<button type="button" class="btn btn-sm btn-danger waves-effect" onclick="deleteNoticeId(<%=noticeList.get(i).getNoticeId()%>)">删除</button></td>
                                </tr>
                            <%
                                }
                            %>

                            </tbody>
                        </table>
                    </div>

                </div>
                <!-- [ content ] End -->

                <!-- [ Layout footer ] Start -->
                <nav class="layout-footer footer bg-white">
                    <div class="container-fluid d-flex flex-wrap justify-content-between text-center container-p-x pb-3">
                        <div class="pt-3">
                            <span class="footer-text font-weight-semibold">&copy; <a target="_blank" href="http://www.mobanwang.com/" title="网页模板">网页模板</a></span>
                        </div>
                        <div>
                            <a href="javascript:" class="footer-link pt-3">About Us</a>
                            <a href="javascript:" class="footer-link pt-3 ml-4">Help</a>
                            <a href="javascript:" class="footer-link pt-3 ml-4">Contact</a>
                            <a href="javascript:" class="footer-link pt-3 ml-4">Terms &amp; Conditions</a>
                        </div>
                    </div>
                </nav>
                <!-- [ Layout footer ] End -->

            </div>
            <!-- [ Layout content ] Start -->

        </div>
        <!-- [ Layout container ] End -->

    </div>

    <!-- Overlay -->
    <div class="layout-overlay layout-sidenav-toggle"></div>
</div>
<!-- [ Layout wrapper ] end -->

<!-- Core scripts -->
<script src="assets/js/pace.js"></script>
<%--<script src="assets/js/jquery-3.3.1.min.js"></script>--%>
<script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.1.3/jquery.min.js">
<script src="assets/libs/popper/popper.js"></script>
<script src="assets/js/bootstrap.js"></script>
<script src="assets/js/sidenav.js"></script>
<script src="assets/js/layout-helpers.js"></script>
<script src="assets/js/material-ripple.js"></script>

<!-- Libs -->
<script src="assets/libs/perfect-scrollbar/perfect-scrollbar.js"></script>

<!-- Demo -->
<script src="assets/js/demo.js"></script><script src="assets/js/analytics.js"></script>

<script type="text/javascript">
    function toAddNoticePage(){
        window.location.href="toAddNoticePage"
    }

    function deleteNoticeId(id){
        var x;
        var r = confirm("确认删除此数据！");
        if(r==true){
            console.log(id);
            $.ajax({url:"deleteNoticeId", data:{noticeId:id}, success:function (result){
                   alert(result);
                   //刷新页面
                    window.location.href="toNoticeManagePage";
                }});
        }
    }

    function selectNotice(){

        var title = $("#t_title").val();
        var content = $("#t_content").val();

        $.ajax({url:"selectNotice", data:{noticeTitle:title, noticeContent:content}, success:function (result){

                alert(JSON.stringify(result));
            }});
    }
</script>

</body>

</html>
